#include "Sql_list.h"

Elenemt_data Stu_data[50] =
    {
        {.name = "刘备", .sex = "男", .sco = 60, .age = 18, .id = 1, .password = "123",.permission = "root"},
        {.name = "关羽", .sex = "男", .sco = 60, .age = 18, .id = 2, .password = "123",.permission = "root"},
        {.name = "张飞", .sex = "女", .sco = 60, .age = 18, .id = 3, .password = "123",.permission = "root"},
        {.name = "诸葛", .sex = "男", .sco = 60, .age = 18, .id = 4, .password = "123",.permission = "root"},
        {.name = "赵云", .sex = "男", .sco = 60, .age = 18, .id = 5, .password = "123",.permission = "root"},
        {.name = "马超", .sex = "男", .sco = 60, .age = 18, .id = 6, .password = "123",.permission = "root"},
        {.name = "祝融", .sex = "女", .sco = 60, .age = 18, .id = 7, .password = "123",.permission = "root"},
        {.name = "小乔", .sex = "女", .sco = 60, .age = 18, .id = 8, .password = "123",.permission = "pull"},
        {.name = "大乔", .sex = "女", .sco = 60, .age = 18, .id = 9, .password = "123",.permission = "pull"},
        {.name = "貂蝉", .sex = "女", .sco = 60, .age = 18, .id = 10, .password = "123",.permission = "pull"}};

void test(void)
{
    Link_list *L = init_link_list();

    // 创建动态空间 给 结点
    Node *new_node = (Node *)malloc(sizeof(Node)); // 创建结点
    L->next = new_node;                            // 将结点 链接到 头节点

    L->next->data = Stu_data[0];
    // printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d\n",
    //     L->next->data.name , L->next->data.sex , L->next->data.age ,
    //     L->next->data.sco  , L->next->data.id
    //     );
    // 第二个结点
    new_node = (Node *)malloc(sizeof(Node)); // 创建结点
    new_node->next = NULL;
    L->next->next = new_node;
    L->next->next->data = Stu_data[1];

    tail_insert_node(&L, Stu_data[3]);

    // 遍历
    Node *ptr = L->next;
    for (size_t i = 0; ptr != NULL; i++)
    {
        printf("姓名:%s 性别:%s 年龄:%d 成绩:%d 学号:%d 密码：%s\n",
               ptr->data.name, ptr->data.sex, ptr->data.age,
               ptr->data.sco, ptr->data.id, ptr->data.password);
        ptr = ptr->next;
    }
    printf("*************\n");

    tail_delete_node(&L);
    print_link_list(L);

    printf("*************\n");

    insert_node(L, Stu_data[3], 2);
    print_link_list(L);

    printf("*************\n");
    Link_list *L1 = init_link_list();
    for (size_t i = 0; i < 3; i++)
    {
        tail_insert_node(&L1, Stu_data[i]);
        print_link_list(L1);
    }
    Link_list *list3 = merge_link_lists(L, L1);
    print_link_list(list3);

    printf("*************\n");
    char str_1[100];//帐号
    char str_2[10]; // 密码
    Link_list *str_3[50];
    printf("请输入一个帐号： ");
    scanf("%s", str_1);
    printf("请输入密码： ");
    scanf("%s", str_2);
    sign_in(L, str_1, str_2);
    Identity(L,str_1);
    // printf("%s\n,%s",L->next->data.permission,str_1);
    
    

    free_link_list(&L);
}

int main(int argc, char const *argv[])
{
    test();
    return 0;
}
